package quoridor;

public class Validator {
	
	public Validator() {
	}
	
	public boolean check(String moves) 
	{
	   if (moves.length() == 0)
	      return true;
	   String[] sliced = moves.split("\\s+");
	   QuoridorBoard board = new QuoridorBoard();
	   QuoridorMove move = null;
	   for (String step : sliced)
	   {
	      if (board.isOver())
	      {
            return false;
         }
	      move = (QuoridorMove) Converter.stringToMove(step, board.currentPlayer());
	      if (board.validateMove(move))
	         board.makeMove(move);
	      else
	      {
	         return false;
	      }
	   }
	   return true;
	}

}